<ng-container [formGroup]="controlContainer.control">
  <div class="d-flex align-items-center justify-content-between" *ngIf="!preview">
    <m-switch-checkbox formControlName="all">选择本区内所有终端</m-switch-checkbox>
    <m-switch-checkbox formControlName="auth">配置终端登录权限</m-switch-checkbox>
  </div>
  <m-api-data-table
    [dataSource]="preview || dataSource"
    [selection]="selection"
    [markSelected]="preview || controlContainer.value.all"
  >
    <ng-container mDataTableColumn header="终端别名">
      <ng-template let-name="name">
        <td>{{ name }}</td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="终端备注">
      <ng-template let-remark="remark">
        <td>{{ remark }}</td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="在线状态">
      <ng-template let-online="online">
        <td>
          <m-online-status-text [status]="online"></m-online-status-text>
        </td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="状态">
      <ng-template let-status="status">
        <td>
          <m-enable-status-text [status]="status"></m-enable-status-text>
        </td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="当前授权人员">
      <ng-template let-auth="user_auth">
        <td><m-auth-type [type]="auth"></m-auth-type></td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="当前终端配置">
      <ng-template let-config="pc_config">
        <td><m-auth-type [type]="config"></m-auth-type></td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="当前系统状态">
      <ng-template let-need_upgrade="need_upgrade">
        <td>
          <m-update-status-text [status]="need_upgrade"></m-update-status-text>
        </td>
      </ng-template>
    </ng-container>
    <ng-container mDataTableColumn header="系统更新时间">
      <ng-template let-upgrade_at="upgrade_at" let-created_at="created_at">
        <div *ngIf="upgrade_at === '0001-01-01T00:00:00Z' ">
          <td>{{ created_at | date }}</td>
        </div>
        <div *ngIf="upgrade_at !== '0001-01-01T00:00:00Z' ">
          <td>{{ upgrade_at | date }}</td>
        </div>
      </ng-template>
    </ng-container>
  </m-api-data-table>
</ng-container>
